package com.fanketly.musicdiary.test

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.width
import androidx.compose.material.Slider
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.ExperimentalTextApi
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.style.Hyphens
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.fanketly.musicdiary.ui.theme.TestTheme
import com.fanketly.musicdiary.ui.theme.White

@Preview
@Composable
fun TextHyphensPreview() {
    TestTheme {
        TextDemoHyphens()
    }
}

/**
 *Version 1.3.0-rc01 添加了新的实验性 API 连字符以支持文本中的自动连字符
 **/

@OptIn(ExperimentalTextApi::class)
@Composable
fun TextDemoHyphens() {
    val text = "TextDemoHyphens"
    val textStyleHyphensOn = TextStyle(
        fontSize = 25.sp, color = Color.Red,
        hyphens = Hyphens.Auto
    )
    val textStyleHyphensOff = TextStyle(
        fontSize = 25.sp, color = Color.Blue,
        hyphens = Hyphens.None
    )
    Column() {
        var width by remember { mutableStateOf(30f) }
        Slider(
            value = width,
            onValueChange = { width = it },
            valueRange = 20f..400f
        )
        Column(Modifier.width(width.dp)) {
            Text(text = text, style = textStyleHyphensOn)
            Text(text = text, style = textStyleHyphensOff)
        }
    }
}